Skip to main content

Unit Properties

The Unit class provides a wide range of properties to access information about game units. Below is a comprehensive list of these properties, along with examples of how to use them.

Identification

id()

Returns the unit's ID

local unitId = unit:id()
if unit:id() == 12345 then
print("Object ID is 1234")
end

name()

Returns the unit's name

if player:name() == "Panglo" then
CrashClient()
end

guid()

Returns the unit's GUID

if player:guid() == target:guid() then
print("We are one")
end

level()

Returns the unit's Level

if player:level() == 69 then
print("Stop")
end

Type and Role

isplayer()

Checks if the unit is a player

if player:isplayer() then
print("Who wouldv'e thought...")
end

ispet()

Checks if the unit is a pet

if target:ispet() then
print("It's a Snake Aaaaahh!")
end

isboss()

Checks if the unit is a boss

if target:isboss() then
print("Better run)
end

specid()

Returns the units Specialisation ID

Click to expand LT.Enums.Class
LT.Enums.Class = {
DEATHKNIGHT = 1,
DEMONHUNTER = 2,
DRUID = 3,
HUNTER = 4,
MAGE = 5,
MONK = 6,
PALADIN = 7,
PRIEST = 8,
ROGUE = 9,
SHAMAN = 10,
WARLOCK = 11,
WARRIOR = 12
}
Click to expand LT.Enums.Spec
LT.Enums.Spec = {
-- Death Knight
BLOOD = 250,
FROST_DK = 251,
UNHOLY = 252,
-- Demon Hunter
HAVOC = 577,
VENGEANCE = 581,
-- Druid
BALANCE = 102,
FERAL = 103,
GUARDIAN = 104,
RESTORATION_DRUID = 105,
-- Hunter
BEASTMASTERY = 253,
MARKSMANSHIP = 254,
SURVIVAL = 255,
-- Mage
ARCANE = 62,
FIRE = 63,
FROST_MAGE = 64,
-- Monk
BREWMASTER = 268,
WINDWALKER = 269,
MISTWEAVER = 270,
-- Paladin
HOLY_PALADIN = 65,
PROTECTION_PALADIN = 66,
RETRIBUTION = 70,
-- Priest
DISCIPLINE = 256,
HOLY_PRIEST = 257,
SHADOW = 258,
-- Rogue
ASSASSINATION = 259,
OUTLAW = 260,
SUBTLETY = 261,
-- Shaman
ELEMENTAL = 262,
ENHANCEMENT = 263,
RESTORATION_SHAMAN = 264,
-- Warlock
AFFLICTION = 265,
DEMONOLOGY = 266,
DESTRUCTION = 267,
-- Warrior
ARMS = 71,
FURY = 72,
PROTECTION_WARRIOR = 73
}
local specID = unit:specid()
if specID == LT.Enums.Spec.RESTORATION_DRUID then
print("This unit is a Restoration Druid")
end

role()

Returns the unit's role in a group

if player:role() == "DAMAGER" then
print("Im a DPS")
end

ishealer()

Checks if the unit is a healer

if unit:ishealer() then
print("It's a healer!")
end

isdps()

Checks if the unit is a DPS

if unit:isdps() then
print("It's a DPS!")
end

istank()

Checks if the unit is a tank

if unit:istank() then
print("It's a tank!")
end

isunit(target)

Checks if the unit is the same as the argument

if target:isunit(target) then
print("Its the same)
end

Health and Status

health()

Returns current health

if player:health() == 0 then
print("And we are dead")
end

healthmax()

Returns maximum health

if unit:healthmax() >= 800000000 then
print("Its probably a Boss")
end

healthpercent()

Returns health percentage

local healthPercent = unit:healthpercent()

hp()

Alias for healthpercent

if target:hp() <= 20 then
--Execute logic
end

isdead()

Checks if the unit is dead

if unit:isdead() then
print("Unit is dead")
end

Casting Information

The castinginfo methods provide information about spells being cast by the unit. There are 9 different methods, each returning a specific piece of information about the cast.

isinterruptible()

Returns if the units cast can be interrupted

if target:isinterruptible() then
--interrupt
end

Available Methods

  • unit:castinginfo(): Returns the name of the spell being cast
  • unit:castinginfo2(): Returns the text of the spell being cast
  • unit:castinginfo3(): Returns the texture of the spell being cast
  • unit:castinginfo4(): Returns the start time of the cast in milliseconds
  • unit:castinginfo5(): Returns the end time of the cast in milliseconds
  • unit:castinginfo6(): Returns whether the cast is a trade skill
  • unit:castinginfo7(): Returns the cast ID
  • unit:castinginfo8(): Returns whether the cast is not interruptible
  • unit:castinginfo9(): Returns the spell ID of the cast

Usage Example

local spellName = unit:castinginfo()
local castStartTime = unit:castinginfo4()
local castEndTime = unit:castinginfo5()
local isNotInterruptible = unit:castinginfo8()
if spellName then
local castDuration = (castEndTime - castStartTime) / 1000
print(unit:name() .. " is casting " .. spellName .. " for " .. castDuration .. " seconds")
if isNotInterruptible then
print("This cast cannot be interrupted!")
end
end

Casting

The :casting() method checks if the unit is currently casting a spell and returns the name of the Spell.

Usage

if player:casting() == "Healing Surge" then
print("Heal incoming")
end

castpct()

The castpct method calculates the percentage of completion for a spell being cast.

if unit:castpct() >= 80 then
--Interrupt Logic
end

timecasting()

Returns the time the Unit has been casting for

local s0ul = getMostDrunk()
if s0ul:timecasting() >= 50 then
print("Enough playtime now s0ul.")
end

Channeling Information

The channelinfo methods provide information about spells being channeled by the unit. There are 8 different methods, each returning a specific piece of information about the channel.

Available Methods

  • unit:channelinfo(): Returns the name of the spell being channeled
  • unit:channelinfo2(): Returns the text of the spell being channeled
  • unit:channelinfo3(): Returns the texture of the spell being channeled
  • unit:channelinfo4(): Returns the start time of the channel in milliseconds
  • unit:channelinfo5(): Returns the end time of the channel in milliseconds
  • unit:channelinfo6(): Returns whether the channel is a trade skill
  • unit:channelinfo7(): Returns whether the channel is not interruptible
  • unit:channelinfo8(): Returns the spell ID of the channeled spell

Usage Example

local channelName = unit:channelinfo()
local channelStartTime = unit:channelinfo4()
local channelEndTime = unit:channelinfo5()
local isNotInterruptible = unit:channelinfo7()
if channelName then
local channelDuration = (channelEndTime - channelStartTime) / 1000
print(unit:name() .. " is channeling " .. channelName .. " for " .. channelDuration .. " seconds")
if isNotInterruptible then
print("This channel cannot be interrupted!")
end
end

Channeling

The :channeling() method checks if the unit is currently casting a spell and returns the name of the Spell.

Usage

if player:channeling() then
print("do something")
end

channelpct()

The channelpct method calculates the percentage of completion for a channel being cast.

if unit:channelpct() >= 80 then
--Interrupt Logic
end

timechanneling()

Returns the time the Unit has been channeling for

if unit:timechanneling() >= 50 then
print("Will he ever stop channeling?")

Diminishing Returns

getDRStep(category)

Retrieves the current DR (Diminishing Returns) step for a given category.

local currentStep = target:getDRStep("stun")
print("Current DR step for stun:", currentStep)

Parameters

  • category (string): The DR category to query (e.g., "stun", "disorient", "taunt").

Returns

  • (number): Current DR step (0 if no DR is active).

getDRRemaining(category)

Retrieves the remaining time before the DR effect for a given category expires.

local remainingTime = target:getDRRemaining("disorient")
print("Time remaining on disorient DR:", remainingTime, "seconds")

Parameters

  • category (string): The DR category to query (e.g., "stun", "disorient", "taunt").

Returns

  • (number): Remaining time in seconds (0 if no DR is active or DR has expired).

isImmune(category)

Checks if the unit is currently immune to a specific DR category.

if target:isImmune("taunt") then
print("Target is immune to taunts!")
else
print("Target can be taunted.")
end

Parameters

  • category (string): The DR category to check (e.g., "stun", "disorient", "taunt").

Returns

  • (boolean): true if immune, false otherwise.

Equipment

hasequipped(slot,itemType)

Checks if a specific type of item is equipped in a given inventory slot.

  • slot (number): The inventory slot ID to check. Use LT.Enums.InvSlotName for slot IDs.
  • itemType (string|number|table, optional): The type of item to check for. Can be a string, number (subclassID), or a table of strings and/or numbers.
-- Check if any item is equipped in the chest slot
player:hasequipped(LT.Enums.InvSlotName.Chest)

-- Check if plate armor is equipped in the chest slot
player:hasequipped(LT.Enums.InvSlotName.Chest, "Plate")

-- Check if plate armor is equipped in the chest slot using subclassID
player:hasequipped(LT.Enums.InvSlotName.Chest, LT.Enums.ItemArmorSubclass.Plate)

-- Check if either plate or mail armor is equipped in the chest slot
player:hasequipped(LT.Enums.InvSlotName.Chest, {"Plate", "Mail"})

-- Check if either plate or mail armor is equipped in the chest slot using subclassIDs
player:hasequipped(LT.Enums.InvSlotName.Chest, {LT.Enums.ItemArmorSubclass.Plate, LT.Enums.ItemArmorSubclass.Mail})

Position and Movement

position()

Returns the unit's position

local pPos = player:position()
print(pPos.x, pPos,y, pPos.z)

distanceto(target)

Calculates distance to another unit accounting for combatreach of both units

if player:distanceto(target) >= 40 then
--Cast Blink

distancetoliteral(target)

Calculates literal distance to another unit

if player:distancetoliteral(target) <= 30 then
--Cast Fireball

height()

Returns the unit's height

local unitHeight = unit:height()

rotation()

Returns the unit's rotation in Radians

local rot = target:rotation()

speed()

Returns the unit's current speed

if player:speed() == 0 then
print("We are standing")
end

speed2()

Returns the unit's run speed

speed3()

Returns the unit's swim speed

speed4()

Returns the unit's flight speed

standing()

Checks if the unit is standing still

if unit:standing() then
print("Unit is standing")
end

timestanding()

Returns how long the unit has been standing in seconds

local standingTime = unit:timestanding()

timemoving()

Returns how long the unit has been moving in seconds

if player:timemoving() >= 0.4 then
--Cast Angelic Feather
end

Combat and Interaction

incombat()

Checks if the unit is in combat

if unit:incombat() then
print("Unit is in combat")
end

timecombat()

Returns how long the unit has been in combat in seconds

local combatTime = unit:timecombat()

timeoutofcombat()

Returns how long the unit has been out of combat

local outOfCombatTime = unit:timeoutofcombat()

isattackable()

Checks if the unit can be attacked

if unit:isattackable() then
print("Unit can be attacked")
end

isenemy()

Checks if the unit is an enemy

if unit:isenemy() then
print("Hes attacking us")
end

isfriendly()

Checks if the unit is friendly

if unit:isfriendly() then
print("Unit is friendly")
end

threat()

Returns the unit's threat level

local threatLevel = unit:threat()

aggro()

Checks if the unit has aggro

if unit:aggro() then
print("Unit has aggro")
end

enemiesaround(yards)

Returns the Enemies around the unit excluding self

if target:enemiesaround(8) > 1 then
print("Officer , he brings backup)
end

friendsaround(yards)

Returns Frindly Units around around the unit excluding self

if target:friendsaround(8) > 1 then
print("No need for worries")
end

Line of Sight and Facing

los()

Checks if the unit has line of sight to the player

if unit:los() then
print("Unit has LOS")
end

haslos(target)

Checks if the unit has line of sight to another unit

if player:haslos(target) then
print("Player has LOS to target")
end

isfacing(target, degrees)

Checks if the unit is facing another unit, defaults to 180 degrees if degrees is not supplied

if unit:isfacing(targetUnit, 90) then
print("Unit is facing target")
end

isfacingposition(x, y, z, degrees)

Checks if the unit is facing a position

if unit:isfacingposition(100, 200, 50, 45) then
print("Unit is facing position")
end

isvalid()

Checks for existance , los and facing

if target:isvalid() then
--Do combat
end

Available Power Types

The following power types are available:

  • mana
  • rage
  • focus
  • energy
  • combopoints (also accessible as "cp")
  • runes
  • runicpower
  • soulshards (also accessible as "shards")
  • astralpower (also accessible as "ap" or "lunarpower")
  • holypower
  • alternatepower
  • maelstrom
  • chi
  • insanity
  • arcanecharges
  • fury
  • pain
  • essence

Using Power Type Functions

For each power type, the following functions are available:

Current Power Value

local currentMana = unit:mana()
local currentEnergy = unit:energy()
-- Similarly for other power types

Maximum Power Value

local maxMana = unit:manamax()
local maxRage = unit:ragemax()
-- Similarly for other power types

Power Percentage

local manaPercent = unit:manapct()
local focusPercent = unit:focuspct()
-- Similarly for other power types

Power Regeneration Rate

local manaRegen = unit:manaregen()
local energyRegen = unit:energyregen()

Time to Max Power

Calculates the time (in seconds) it will take to reach maximum power at the current regeneration rate.

local timeToMaxMana = unit:manatimetomax()
local timeToMaxRunicPower = unit:runestimetomax()
-- Similarly for other power types

Time to Specific Power Amount

Calculates the time (in seconds) it will take to reach a specific power amount at the current regeneration rate.

local timeTo50Mana = unit:manatimeto(50)
local timeTo100Energy = unit:energytimeto(100)
-- Similarly for other power types

Special Case: Runes

Runes work slightly differently due to their unique mechanics:

  • unit:runes() returns the number of available runes (0-6)
  • unit:runesregen() returns the total regeneration rate of all runes
  • unit:runestimetomax() returns the time until all 6 runes are available
  • unit:runestimeto(n) returns the time until n runes are available

Geometry

isInsideArcOf(unit, size, arc, rotation)

Checks if the current unit is inside an arc of another unit.

local target = LT.Target
local player = LT.Player
if target:isInsideArcOf(player, 10, 90) then
print("Target is inside the 90-degree arc in front of the player!")
else
print("Target is outside the arc.")
end

Parameters

  • unit (Unit): The unit at the center of the arc.
  • size (number): The radius of the arc.
  • arc (number): The angle of the arc in degrees.
  • rotation (number, optional): The rotation of the arc in radians. If not provided, uses the unit's rotation.

Returns

  • (boolean): true if the unit is inside the arc, false otherwise.

Miscellaneous

afk()

Checks if the unit is AFK

if unit:afk() then
print("Unit is AFK")
end

class()

Returns the unit's class

local unitClass = unit:class()

gcdremains()

Returns the remaining time on the Global Cooldown (GCD).

local gcdRemaining = player:gcdremains()
if gcdRemaining > 0 then
print("GCD will end in " .. string.format("%.2f", gcdRemaining) .. " seconds")
else
print("GCD is not active")
end

getpointer()

Returns the WoWGameObject to be reused

print(UnitHealth(player:getpointer()))
if unit:ingroup() then
print("Unit is in group")
end

interact()

Interacts with the Unit

LT.Corpses:loop(function(corpse)
if corpse:islootable() and corpse:distanceto(LT.Player) <= 5 then
corpse:Interact()
end
end)

ingroup()

Checks if the unit is in the player's group

if target:ingroup() then
print("target is in your group or raidgroup)
end

settarget()

Sets the Unit as your target

if not enemy:isunit(target) then
enemy:settarget()
end

setfocus()

Sets the Unit as your focus

if not enemy:isunit(focus) then
enemy:setfocus()
end

race()

Returns the unit's race

local unitRace = unit:race()
if unitRace == "DWARF" then
print("Who even plays you?!")
end

creatureType()

Returns the unit's creature type

local creatureType = unit:creatureType()

isoutdoors()

Checks if the unit is outdoors

if unit:isoutdoors() then
print("Unit is outdoors")
end

isindoors()

Checks if the unit is indoors

if unit:isindoors() then
print("Unit is indoors")
end

issubmerged()

Checks if the unit is submerged

if unit:issubmerged() then
print("Unit is submerged")
end

ismounted()

Checks if the unit is mounted

if unit:ismounted() then
print("Unit is mounted")
end

ttd()

Returns the Units expected time to die in seconds

if target:ttd() >= 16 then
print("Safe to use CDS")
end

uptime()

Returns for how long the unit has been in the Objectmanager

if totem:uptime() >= 0.5 then
"Hawk tuah! Stomp that thang!"
end